package cn.itcast.nems.employee.dao.bean;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class EmployeeGroupsBean {
    private List<EmployeeGroupBean> groupList;

    /**
     * 检查是否有用户组
     *
     * @return 是否有用户组
     */
    public boolean hasEmployeeGroups() {
        if (groupList == null || groupList.isEmpty()) {
            return false;
        }
        return true;
    }

    /**
     * 检查是否拥有指定校区及学科的数据权限
     *
     * @param campusId  校区code
     * @param subjectId 学科code
     * @return 是否有权限
     */
    public boolean hasEmployeeGroups(String campusId, String subjectId) {
        for (EmployeeGroupBean employeeGroupBean : groupList) {
            if (employeeGroupBean.getSchoolCodeList().contains(campusId)
                    && employeeGroupBean.getSubjectIdList().contains(subjectId)) {
                return true;
            }
        }
        return false;
    }
}
